﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace tpos_custom_control
{
    public partial class uc_bill_item : UserControl
    {
        private string item_code = "";

        public uc_bill_item()
        {
            InitializeComponent();
        }

        public string uc_ItemCode {
            set { this.item_code = value; }
            get { return this.item_code; }
        }

        public string uc_ItemName {
            set { lbl_item_name.Text = value; }
            get { return lbl_item_name.Text; }
        }

        public string uc_PriceText {
            set { lbl_price_text.Text = value; }
            get { return lbl_price_text.Text; }
        }

        public decimal uc_PriceNumber {
            set { lbl_price_number.Text = value.ToString(); }
            get { return decimal.Parse(lbl_price_number.Text); }
        }

        public string uc_PriceUnit {
            set { lbl_price_unit.Text = value; }
            get { return lbl_price_unit.Text; }
        }

        public string uc_QuantityText {
            set { lbl_quantity_text.Text = value; }
            get { return lbl_quantity_text.Text; }
        }

        public double uc_QuantityNumber {
            set { lbl_quantity_number.Text = value.ToString(); }
            get { return double.Parse(lbl_quantity_number.Text); }
        }

        public string uc_QuantityUnit{
            set { lbl_quantity_unit.Text = value; }
            get { return lbl_quantity_unit.Text; }
        }

        public void uc_AddNote(string note) {
            Label lbl_note = new Label();
            lbl_note.Name = "lbl_note_" + DateTime.Now.ToString("yyyyMMdd_hhmmss");
            lbl_note.Text = note;
            lbl_note.Height = 20;
            lbl_note.AutoSize = false;
            lbl_note.Dock = DockStyle.Top;
            pl_note.Controls.Add(lbl_note);
            this.Height = this.Height + lbl_note.Height;
            pl_note.Height = pl_note.Height + lbl_note.Height;
        }

        public string uc_GetNote() {
            string note = "";
            foreach (Control ctrl in pl_note.Controls) {
                if (ctrl is Label) {
                    if (ctrl.Name.IndexOf("lbl_note_") >= 0) {
                        note += ((Label)ctrl).Text + "\n\r";
                    }
                }
            }
            return note;
        }

        public Color uc_BackColor {
            set { this.BackColor = value; }
            get { return this.BackColor; }
        }

        private void uc_bill_item_Load(object sender, EventArgs e)
        {
            this.uc_BackColor = Color.White;
        }

    }
}
